package org.gw.building.repositories;

import java.util.List;

import org.gw.building.model.Tzgg;
import org.gw.building.model.base.TzggFj;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

public interface TzggRepository extends CrudRepository<Tzgg, String> {
	@Query("from Tzgg t where (?1 is null or t.id = ?1) and (?2 is null or t.bt like ?2) and (?3 is null or t.fbr like ?3) " +
		" and (?4 is null or t.fbzt = ?4) order by t.xgsj desc")
	Page<Tzgg> queryPage(String id, String bt, String fbr, String fbzt, Pageable pageable);

	/*@Query("from Tzgg t where  t.cc.dm < ?1 and t.ssyx = ?2 order by t.px desc")
	List<Tzgg> query(String cc, String ssyx);*/

	@Query("from Tzgg t where t.id = ?1")
	Tzgg findById(String id);
	
	@Query("from TzggFj t where t.tzggid = ?1 order by t.scsj desc")
	List<TzggFj> findFjByOwner(String id);
}
